﻿@{
    ViewBag.Title = "病例报告列表";
    Layout = "~/Views/Shared/Master.cshtml";
}

@{Html.Telerik().Window().Name("CRFListSelfWindouw").Title("病例报告列表").HtmlAttributes(new { @class = "ContentLargeWindow" })
    .Buttons(buttons => buttons.Clear())
    .Content(
@<text>
@(Html.Telerik().Grid<CRF>().Name("CRFListSelfGrid")
    .ToolBar(config =>
    {
        config.Custom().Name("Add").Text("添加病例报告").Action<CRFController>(c => c.CRFAddSelf());
    })
    .DataKeys(keys => keys.Add(crf => crf.ID))
    .Columns(columns =>
    {
        columns.Bound(crf => crf.ID).Hidden();
        columns.Bound(crf => crf.HospitalCode).Title("医院编号").Filterable(true);
        columns.Bound(crf => crf.CrfCode).Title("病例序号").Filterable(true);
        columns.Bound(crf => crf.ResearcherID).Hidden();
        columns.Bound(crf => crf.Researcher.RealName).Title("研究者");
        columns.Bound(crf => crf.StartTime).Title("开始时间");
        columns.Command(commands =>
        {
            commands.Custom("Detail").Text("详情").Ajax(true);
            if (LoginSession.IsAdministrator||LoginSession.IsOwner)
                commands.Delete();

        })
      .Title("操作");
    })
    .ClientEvents(events =>
    {
        events.OnCommand("OnCommand");
    })
    .DataBinding(bind =>
    {
        bind.Ajax().Select<CRFController>(c => c._CRFlistSelf())
            .Delete<CRFController>(c => c._CRFDelete(null));
    }
    ).Pageable(pager => pager.PageSize(10).Style(GridPagerStyles.NextPreviousAndNumeric))
    .Filterable(filtering => filtering.Enabled(true))
    .Editable(edit => edit.Mode(GridEditMode.InLine))
    .Sortable(sort=>sort.SortMode(GridSortMode.MultipleColumn).OrderBy(ord=>ord.Add(o=>o.StartTime)))
  )
</text>
).Render();
}
<script type="text/javascript">
    function Detail(id) {
        var url = "@(Url.Action<CRFController>(c => c.CRFDetail(Guid.Empty)))";
        url = url.replace("@Guid.Empty", id);
        window.location = url;
    }
    function OnCommand(e) {
        switch (e.name) {
            case "Detail": Detail(e.dataItem.ID); break;
        }
    }
</script>
